package org.jeecg.modules.filemanage.base.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.jeecg.modules.filemanage.base.mapper.BIReportMapper;
import org.jeecg.modules.filemanage.base.service.IBIReportService;
import org.jeecg.modules.filemanage.base.vo.fileInOutView;
import org.jeecg.modules.filemanage.base.vo.fileSearchView;
import org.jeecg.modules.filemanage.base.vo.fileTypeRadioView;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

@Service
public class BIReportServiceImpl implements IBIReportService {
    @Autowired
    private BIReportMapper biReportMapper;



   public List<fileTypeRadioView> fileTypeRadio(String fileType){
        List<fileTypeRadioView> res = new ArrayList<>();
        res = this.biReportMapper.fileTypeRadio(fileType);
        return res;
    }

    public List<fileInOutView> fileInOut(String branchId){
        List<fileInOutView> res = new ArrayList<>();
        //取需求信息
        List<fileInOutView> requestList = biReportMapper.demandinfo(branchId);
       for(fileInOutView r :res){
           for(fileInOutView s:requestList)
           {
               if(s.getBranchid().equalsIgnoreCase(r.getBranchid()))
                   r.setRequestNum(s.getRequestNum());
           }
       }
        //取导出记录
        List<fileInOutView> supportList =  biReportMapper.exportinfo(branchId);
        for(fileInOutView r :res){
            for(fileInOutView s:supportList)
            {
                if(s.getBranchid().equalsIgnoreCase(r.getBranchid()))
                    r.setSupportNum(s.getSupportNum());
            }
        }

        return res;
    }

   public Page<fileSearchView>fileSearch (Page<fileSearchView> page,String keyword){
       return page.setRecords(biReportMapper.fileSearch(page,keyword));
    }

    @Override
    public Page<fileSearchView> fileHot(Page<fileSearchView> page, String userId, String msgCategory){
        return page.setRecords(biReportMapper.fileHot(page, userId, msgCategory));
    }

}
